from django import forms
from mood import models
import time
import datetime


class MoodModelForm(forms.ModelForm):
    intro = forms.CharField(
        label='简介',
        min_length=1,
        max_length=150,
        error_messages={
            'min_length': "输入您的心情",
            'max_length': "您的心情超字数啦！"
        },
        widget=forms.Textarea(attrs={'class': "form-control border-0 p-0 shadow-none min-vh-15",
                                     'aria-describedby': 'button-addon2',
                                     'placeholder': "请写下你的心里话......",
                                     'rows': "1",
                                     'data-emojiable': "true",
                                     })
    )

    class Meta:
        model = models.Mood

        fields = ['intro', 'is_public']  # 获取字段，按列表顺序展示
        widgets = {
            'is_public': forms.Select()
        }


class MoodImageModelForm(forms.ModelForm):

    class Meta:
        model = models.MoodImage

        fields = ['file_url'] # 获取字段，缩略图